package com.baturu.vin.benz.dal.dao;

import com.baturu.vin.benz.dto.BenzSuperSubGroupDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * BenzSubGroupDAO
 * 子组相关查询
 *
 * @author majianming
 * @date 2019-04-19 15:19
 */
public interface BenzSubGroupDAO {

    /**
     * 通过车型和子组查询子组
     *
     * @param langCode
     * @param carNo
     * @param mainGroupNo
     * @return
     */
    @Select({"SELECT CATNUM catNum,GROUPNUM mainGroupNo,LANG langCode,SUBGRP subGroupNo,TEXT `desc` from BM_SUBGRP_V",
            "WHERE CATNUM=#{catNum} AND  LANG=#{langCode} AND GROUPNUM=#{mainGroupNo}"})
    List<BenzSuperSubGroupDTO> querySubGroupByMainGroup(@Param("langCode") String langCode,
                                                        @Param("catNum") String carNo,
                                                        @Param("mainGroupNo") String mainGroupNo);


    /**
     * 通过子组编号等信息查询子组
     *
     * @param subGroupDTOS
     * @return
     */
    @Select({"<script>",
            "SELECT CATNUM catNum,GROUPNUM mainGroupNo,LANG langCode,SUBGRP subGroupNo,TEXT `desc` from BM_SUBGRP_V",
            "WHERE (CATNUM,LANG,GROUPNUM,SUBGRP) IN ",
            "<foreach item = 'subGroupDTO' index = 'index' collection = 'subGroupDTOS' open = '(' separator=',' close=')'> ",
            "(#{subGroupDTO.catNum},#{langCode},#{subGroupDTO.mainGroupNo},#{subGroupDTO.subGroupNo})",
            "</foreach>",
            "</script>",})
    List<BenzSuperSubGroupDTO> querySubGroupBySubGroup(@Param("subGroupDTOS") List<BenzSuperSubGroupDTO> subGroupDTOS, @Param("langCode") String langCode);
}
